package cn.echase.ecare.yinfayun.service.impl;

import cn.echase.ecare.yinfayun.domain.entity.UcElderlyPatients;
import cn.echase.ecare.yinfayun.domain.mapper.UcElderlyPatientsMapper;
import cn.echase.ecare.yinfayun.service.UcElderlyPatientsService;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 长者管理实体类操作服务层实现类
 */
@Service
public class UcElderlyPatientsServiceImpl implements UcElderlyPatientsService {

    @Resource
    private UcElderlyPatientsMapper ucElderlyPatientsMapper;

    @Override
    public String getName(String ucId) {
        if (ucId == null) {
            return "暂无数据";
        }
        LambdaQueryWrapper<UcElderlyPatients> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.select(UcElderlyPatients::getName);
        queryWrapper.eq(UcElderlyPatients::getUcId, ucId);
        List<String> nameList = ucElderlyPatientsMapper.selectObjs(queryWrapper);
        if (CollUtil.isEmpty(nameList)) {
            return null;
        }

        return nameList.get(0);
    }

}
